package logic

import (
	"context"
	"errors"
	"goods_srv/model/mysql"
	"gorm.io/gorm"

	"goods_srv/goods"
	"goods_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DetailGoodsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDetailGoodsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DetailGoodsLogic {
	return &DetailGoodsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DetailGoodsLogic) DetailGoods(in *goods.DetailGoodsRequest) (*goods.DetailGoodsResponse, error) {
	g := mysql.Goods{}
	err := g.Detail(in.GoodsId)
	if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
		logx.Error("商品详情查询失败", err)
		return nil, err
	}

	return &goods.DetailGoodsResponse{}, nil
}
